﻿
using System.Collections.Generic;

namespace LxCFD
{
    public abstract class Value1List
    {
        public abstract class Base<T> : Value1Base<T>
        {
            public List<Value1Base<T>> Value1s = new List<Value1Base<T>>();
        }
        public class Double : Base<double>
        {
            public override double GetCellValue(int cellIndex)
            {
                double total = 0;
                foreach (var v in Value1s)
                {
                    total += v.GetCellValue(cellIndex);
                }
                return total;
            }
            public override double GetFaceValue(int faceIndex)
            {
                double total = 0;
                foreach (var v in Value1s)
                {
                    total += v.GetFaceValue(faceIndex);
                }
                return total;
            }
            public override Value1Base<double> GetCopy(HeadBase zoneOrContact)
            {
                Double copy = new Double();
                foreach (var l in Value1s)
                {
                    copy.Value1s.Add(l.GetCopy(zoneOrContact));
                }
                return copy;
            }
        }
        public class Vector : Base<Vector3d>
        {
            public override Vector3d GetCellValue(int cellIndex)
            {
                Vector3d result = new Vector3d();
                foreach (var v in Value1s)
                {
                    result.AddToSelf(v.GetCellValue(cellIndex));
                }
                return result;
            }
            public override Vector3d GetFaceValue(int faceIndex)
            {
                Vector3d result = new Vector3d();
                foreach (var v in Value1s)
                {
                    result.AddToSelf(v.GetFaceValue(faceIndex));
                }
                return result;
            }
            public override Value1Base<Vector3d> GetCopy(HeadBase zoneOrContact)
            {
                Vector copy = new Vector();
                foreach (var l in Value1s)
                {
                    copy.Value1s.Add(l.GetCopy(zoneOrContact));
                }
                return copy;
            }
        }
    }
}
